package cn.jbolt.ai.resource.llm.controller;

import cn.jbolt.ai.resource.llm.entity.AiResource;
import cn.jbolt.ai.resource.llm.service.AiResourceService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * ai资源管理
 */
@Controller
@ResponseBody
@RequestMapping("/aiResource")
@Tag(name = "ai资源管理Controller")
public class AiResourceController {

    @Autowired
    private AiResourceService resourceService;



    @Operation(summary = "根据ID获取资源信息", description = "根据ID获取资源信息")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        return resourceService.getResourceById(id);
    }


    @Operation(summary = "获取所有资源信息", description = "获取所有资源信息")
    @GetMapping("/list")
    public Result getList(Integer page, Integer pageSize,@RequestParam(required = false) String keywords) {
        return resourceService.listByPage(page,pageSize,keywords);
    }

    @Operation(summary = "下拉选获取所有开启的资源信息", description = "下拉选获取所有开启的资源信息")
    @GetMapping("/listAllEnabledType")
    public Result listAllEnabledType() {
        return resourceService.listAllEnabledType();
    }

    @Operation(summary = "添加新的资源", description = "添加新的资源")
    @PostMapping("/add")
    public Result add(@RequestBody AiResource resource) {
        return resourceService.add(resource);
    }


    @Operation(summary = "更新资源信息", description = "更新资源信息")
    @PostMapping("/update")
    public Result update(@RequestBody AiResource resource) {
        return resourceService.update(resource);
    }


    @Operation(summary = "删除资源", description = "删除资源")
    @GetMapping("/del/{id}")
    public Result del(@PathVariable Long id) {
        return resourceService.del(id);
    }


    @Operation(summary = "修改资源的启用状态", description = "修改资源的启用状态")
    @GetMapping("/toggleEnable/{id}")
    public Result toggleEnable(@PathVariable Long id) {
        return resourceService.toggleEnable(id);
    }
}
